package com.coc.ofhibernate.service.impl;

import com.coc.ofhibernate.dao.UserMapper;
import com.coc.ofhibernate.entity.database1.User;
import com.coc.ofhibernate.service.UserService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserServiceImpl implements UserService {

    private static final Logger logger = LoggerFactory.getLogger(UserServiceImpl.class);


    @Autowired
    private UserMapper userMapper ;



    @Override
    public List<User> listAll() {
        return userMapper.findAll();
    }

    @Override
    public void insertUser(User user) {
        userMapper.save(user);
        logger.info( "插入数据成功" + user.toString());
    }

    @Override
    public User getUserById(int id) {
       return userMapper.getUserById(id);
    }

    @Override
    public List<User> getUserListByName(String username) {
        return userMapper.getUserListByName(username);
    }


}
